package com.huike.web.controller.clues;

import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.dto.TbActivityDTO;
import com.huike.clues.service.TbActivityService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动管理Controller
 *
 * @date 2023-04-01
 */
@RestController
@RequestMapping("/clues/activity")
public class TbActivityController extends BaseController {

    @Autowired
    TbActivityService tbActivityService;

    /**
     * 分页查询活动管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbActivityDTO tbActivityDTO) {
        startPage();
        List<TbActivity> list = tbActivityService.listTbActivity(tbActivityDTO);
        return getDataTable(list);
    }
    /**
     * 新增活动管理
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbActivity tbActivity) {
        tbActivityService.add(tbActivity);
        return AjaxResult.success();
    }


    @GetMapping("/{id}")
    public AjaxResult getDetailsById(@PathVariable Long id) {
        TbActivity tbActivity = tbActivityService.getDetailsById(id);
        return AjaxResult.success(tbActivity);
    }


    @PutMapping
    public AjaxResult update(@RequestBody TbActivity tbActivity) {
        tbActivityService.updateTbActivity(tbActivity);
        return AjaxResult.success();
    }


    @DeleteMapping("/{ids}")
    public AjaxResult delete(@PathVariable Long[] ids) {
        tbActivityService.deleteByIds(ids);
        return AjaxResult.success();
    }


}
